<script type="text/javascript">
$(function() {
	$('#adicionaDesejaveis').click(function() { transfereItem('todas_competencias', 'competencias_desejaveis'); });	
	$('#removeDesejaveis').click(function() { transfereItem('competencias_desejaveis', 'todas_competencias'); });
	$('#adicionaObrigatorios').click(function() { transfereItem('todas_competencias', 'competencias_obrigatorias'); });
	$('#removeObrigatorios').click(function() { transfereItem('competencias_obrigatorias', 'todas_competencias'); });
	$('#moduloForm').submit(function() {
		$('#competencias_desejaveis option').attr('selected', 'selected');
		$('#competencias_obrigatorias option').attr('selected', 'selected');
	});
});
</script>
<div class="content-box"><!-- Start Content Box -->
    
    <div class="content-box-header">
        
        <h3>Ofertas (<?php echo $total;?>)</h3>
        
  <ul class="content-box-tabs">
            <li><a href="#tab1" class="<?php echo $tab_lista;?>">Cadastradas</a></li> <!-- href must be unique and match the id of target div -->
            <li><a href="#tab2" class="<?php echo $tab_form;?>"><?php echo $editar_novo;?></a></li>
        </ul>
        
        <div class="clear"></div>
        
    </div> <!-- End .content-box-header -->
    
    <div class="content-box-content">
        
        <div class="tab-content <?php echo $tab_lista;?>" id="tab1"> <!-- This is the target div. id must match the href of this div's tab -->
            
         	<div class="notification <?php echo $css_mensagens;?> png_bg" <?php echo $display_mensagens;?>>
                <a href="#" class="close"><img src="{base_url}/_img/admin/icons/cross_grey_small.png" title="Fechar esta notifica&ccedil;&atilde;o" alt="Fechar" /></a>
                <div>
                    <?php echo $mensagem;?>
                </div>
            </div>            
		    <form action="" method="post" id="formLista">
            <table>
                
                <thead>
                    <tr>
                       <th style="width:5%;"><input class="check-all" type="checkbox" /></th>
                       <th style="width:auto;">Nome</th>
                       <th style="width:auto;">Pessoa para contato</th>
                       <th style="width:6%;">A&ccedil;&otilde;es</th>
                    </tr>
                    
                </thead>
             
                <tfoot>
                    <tr>
                        <td colspan="4">
                            <div class="bulk-actions align-left">
                            	
                                <select name="dropdownAcoes">
                                    <option value="">Com os selecionados...</option>
                                    <option value="<?php echo site_url("admin/" . $nome_secao ."/apagaVarios")?>">Excluir</option>
                                </select>
                                 
                                <a class="button" id="btAcao" style="cursor: pointer;">Aplicar</a>
                            </div>
                            
                            <div class="pagination"><?php paginator($pagina, $limite, $total_paginas, 'admin/' . $nome_secao .'/' . $lista_busca . '/')?></div>
                            <div class="clear"></div>
                        </td>
                    </tr>
                </tfoot>
             
                <tbody>
				<?php
                if (empty($rs)) {
                ?>
                    <tr>
                        <td colspan="5">Nenhum registro cadastrado.</td>                        
                    </tr>
				<?php
                }
                else {
                
                foreach ((array)$rs as $registro) {
                    $id = $registro->id;
                    $ativado = ($registro->ativo == 0) ? "des" : "";
                    $ativar = ($registro->ativo == 0) ? 1 : 0;
                ?>
                    <tr>
                        <td><input type="checkbox" name="ativo[]" value="<?php echo $id;?>" /></td>

                        <td><?php echo $registro->nome;?></td>
                        <td><?php echo $registro->pessoa_contato;?></td>
                        <td>
                            <!-- Icons -->
                             <a href="<?php echo site_url("admin/" . $nome_secao ."/edita/$id");?>" title="Editar"><img src="{base_url}/_img/admin/icons/pencil.png" alt="Editar" /></a>
                             <a href="<?php echo site_url("admin/" . $nome_secao ."/trataApaga/$id");?>" title="Excluir"><img src="{base_url}/_img/admin/icons/cross.png" alt="Excluir" /></a>
                        </td>                        
                    </tr>
				<?php
                    }
                }
                ?>
                </tbody>
            </table>

            </form>
           
        </div> <!-- End #tab1 -->
        
        <div class="tab-content <?php echo $tab_form;?>" id="tab2">

            <form id="moduloForm" action="<?php echo $action;?>" method="post">
                <fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->

                   <p>
                        <label>Nome da Oferta</label>
                        <input class="text-input medium-input {validate: {required: true}}" type="text" name="nome" value="<?php echo $r->nome;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Atividades</label>
                        <textarea class="{validate: {required: true}}" cols="100" rows="5" name="atividades"><?php echo $r->atividades;?></textarea>
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Remunera&ccedil;&atilde;o</label>
                        <input class="text-input medium-input maskMoney {validate: {required: true}}" type="text" name="remuneracao" value="<?php echo getPreco($r->remuneracao);?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Quantidade de Horas</label>
                        <input class="text-input {validate: {required: true}}" type="text" name="horas" value="<?php echo $r->horas;?>" maxlength="10" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Turno</label>
                        <input class="text-input {validate: {required: true}}" type="text" name="turno" value="<?php echo $r->turno;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Endere&ccedil;o</label>
                        <input class="text-input small-input {validate: {required: true}}" type="text" name="endereco" value="<?php echo $r->endereco;?>" />
                   </p>
                   <p>
                        <label>Telefone de Contato</label>
                        <input class="text-input small-input {validate: {required: true}}" type="text" name="telefone_contato" value="<?php echo $r->telefone_contato;?>" />
                   </p>
                   <p>
                        <label>Nome da Pessoa para Contato</label>
                        <input class="text-input small-input {validate: {required: false}}" type="text" name="pessoa_contato" value="<?php echo $r->pessoa_contato;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Nº de vagas</label>
                        <input class="text-input verysmall-input {validate: {required: true, number: true}}" type="text" name="vagas" value="<?php echo $r->vagas;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                </fieldset>
                <fieldset>
                <table style="width: 300px;" border="0">
                	<tr>
                		<td>
                			<select name="competencias_desejaveis[]" class="{validate: {required: true}}" multiple="multiple" style="height: 186px; float: right;" id="competencias_desejaveis">
<?php
foreach ((array)$competenciasSelecionadas['competencias_desejaveis'] as $id => $nome) {
?>
								<option value="<?php echo $id;?>"><?php echo $nome;?></option>
<?php
}
?>
                			</select>
	                  	</td>
                		<td style="float: left;">
                		<div>Compet&ecirc;ncias Desej&aacute;veis
	                    	<input id="adicionaDesejaveis" type="button" class="button" value="&lt;&lt;" />
                			<input id="removeDesejaveis" type="button" class="button" value=">>" />
                		</div>
	                    </td>
                		<td>Compet&ecirc;ncias
                		<select name="todas_competencias" id="todas_competencias" multiple="multiple" style="height: 186px; float: right;">
                		
<?php
$competencias = array_diff($competencias, (array)$competenciasSelecionadas['competencias_desejaveis'], (array)$competenciasSelecionadas['competencias_obrigatorias']);;
foreach ((array)$competencias as $id => $nome) {
?>
							<option value="<?php echo $id;?>"><?php echo $nome;?></option>
<?php
}
?>
						</select>
                		</td>
                		<td style="float: left;">
                			<div>Compet&ecirc;ncias Obrigat&oacute;rias
                			<input id="adicionaObrigatorios" type="button" class="button" value=">>" />
	                    	<input id="removeObrigatorios" type="button" class="button" value="&lt;&lt;" />
	                    	</div>	
						</td>
                		<td>
                		<select name="competencias_obrigatorias[]" class="{validate: {required: true}}" multiple="multiple" style="height: 186px; float: right;" id="competencias_obrigatorias">
<?php
foreach ((array)$competenciasSelecionadas['competencias_obrigatorias'] as $id => $nome) {
?>
							<option value="<?php echo $id;?>"><?php echo $nome;?></option>
<?php
}
?>
                		</select>
						</td>
                	</tr>
                </table>
                <p>
                       <input class="button" type="submit" value="Salvar" />
                   </p>
                </fieldset>
                <div class="clear"></div><!-- End .clear -->
                
            </form>
            
        </div> <!-- End #tab2 -->        
        
    </div> <!-- End .content-box-content -->
    
</div> <!-- End .content-box -->

<div class="clear"></div>